﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace DefaultNamespace
{
    public class BuilderModel : MonoBehaviour
    {
        private void Start()
        {
            IBuilder fatBuilder = new FatPersonBuilder();
            IBuilder thinBuilder = new ThinPersonBuilder();
            Person fatperson = Director.Construct(fatBuilder);
            fatperson.Show();
        }
    }

    class Person
    {
        private List<string> parts = new List<string>();

        public void AddPart(string part)
        {
            parts.Add(part);
        }

        public void Show()
        {
            foreach (var part in parts)
            {
                Debug.Log(part);
            }
        }
    }

    class FitPerson : Person
    {
    }

    class ThinPerson : Person

    {
    }

    interface IBuilder
    {
        void AddHead();
        void AddBody();
        void AddHand();
        void AddFeet();
        Person GetResult();
    }

    class FatPersonBuilder : IBuilder
    {
        private Person person;

        public FatPersonBuilder()
        {
            person = new FitPerson();
        }

        public void AddHead()
        {
            person.AddPart("Fat Head");
        }

        public void AddBody()
        {
            person.AddPart("Fat Body");
        }

        public void AddHand()
        {
            person.AddPart("Fat Hand");
        }

        public void AddFeet()
        {
            person.AddPart("Fat Feet");
        }

        public Person GetResult()
        {
            return person;
        }
    }

    class ThinPersonBuilder : IBuilder
    {
        private Person person;

        public ThinPersonBuilder()
        {
            person = new ThinPerson();
        }

        public void AddHead()
        {
            person.AddPart("Thin Head");
        }

        public void AddBody()
        {
            person.AddPart("Thin Body");
        }

        public void AddHand()
        {
            person.AddPart("Thin Hand");
        }

        public void AddFeet()
        {
            person.AddPart("Thin Feet");
        }

        public Person GetResult()
        {
            return person;
        }
    }

    class Director
    {
        public static Person Construct(IBuilder builder)
        {
            builder.AddHead();
            builder.AddBody();
            builder.AddHand();
            builder.AddFeet();
            return builder.GetResult();
        }
    }
}